<template>
  <div>
    <h1>Parent -- {{count}}</h1>
    <button @click='addAllNum'>让所有子组件num加1</button>
    <Child1 />
    <Child2 />
  </div>
</template>

<script>
import Child1 from "./Child1";
import Child2 from "./Child2";
export default {
  name: "Parent",
  components: {
    Child1,
    Child2,
  },
  data() {
    return {
      count: 0,
    };
  },
  methods:{
    addAllNum(){
      this.$children.forEach((vc)=>{
        vc.num++
      })
    }
  }
};
</script>

<style>
</style>